using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Neovolve.Windows.Forms.Controls
{
    /// <summary>
    /// The <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class defines settings to be applied to a
    /// <see cref="Neovolve.Windows.Forms.Controls.WizardPage"/> instance.
    /// </summary>
    [
        TypeConverter(typeof(ExpandableObjectConverter ))
    ]
    public class WizardPageSettings
    {
        #region Declarations

        /// <summary>
        /// Defines the default text for the next button.
        /// </summary>
        private const String DefaultNextButtonText = "Next";

        /// <summary>
        /// Stores the settings for the next button.
        /// </summary>
        private WizardButtonSettings _nextButtonSettings;

        /// <summary>
        /// Defines the default text for the previous button.
        /// </summary>
        private const String DefaultPreviousButtonText = "Back";

        /// <summary>
        /// Stores the settings for the previous button.
        /// </summary>
        private WizardButtonSettings _previousButtonSettings;

        /// <summary>
        /// Defines the default text for the cancel button.
        /// </summary>
        private const String DefaultCancelButtonText = "Cancel";

        /// <summary>
        /// Stores the settings for the cancel button.
        /// </summary>
        private WizardButtonSettings _cancelButtonSettings;

        /// <summary>
        /// Defines the default text for the help button.
        /// </summary>
        private const String DefaultHelpButtonText = "Help";

        /// <summary>
        /// Defines the default visible value for the help button.
        /// </summary>
        private const Boolean DefaultHelpButtonVisible = false;

        /// <summary>
        /// Stores the settings for the help button.
        /// </summary>
        private WizardButtonSettings _helpButtonSettings;

        /// <summary>
        /// Defines the default text for the custom button.
        /// </summary>
        private const String DefaultCustomButtonText = "Custom";

        /// <summary>
        /// Defines the default visible value for the custom button.
        /// </summary>
        private const Boolean DefaultCustomButtonVisible = false;

        /// <summary>
        /// Stores the settings for the custom button.
        /// </summary>
        private WizardButtonSettings _customButtonSettings;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        public WizardPageSettings()
            : this(null, null, null, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        /// <param name="nextButton">The next button.</param>
        public WizardPageSettings(
            WizardButtonSettings nextButton)
            : this(nextButton, null, null, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        /// <param name="nextButton">The next button.</param>
        /// <param name="previousButton">The previous button.</param>
        public WizardPageSettings(
            WizardButtonSettings nextButton,
            WizardButtonSettings previousButton)
            : this(nextButton, previousButton, null, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        /// <param name="nextButton">The next button.</param>
        /// <param name="previousButton">The previous button.</param>
        /// <param name="cancelButton">The cancel button.</param>
        public WizardPageSettings(
            WizardButtonSettings nextButton,
            WizardButtonSettings previousButton,
            WizardButtonSettings cancelButton)
            : this(nextButton, previousButton, cancelButton, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        /// <param name="nextButton">The next button.</param>
        /// <param name="previousButton">The previous button.</param>
        /// <param name="cancelButton">The cancel button.</param>
        /// <param name="helpButton">The help button.</param>
        public WizardPageSettings(
            WizardButtonSettings nextButton,
            WizardButtonSettings previousButton,
            WizardButtonSettings cancelButton,
            WizardButtonSettings helpButton)
            : this(nextButton, previousButton, cancelButton, helpButton, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Neovolve.Windows.Forms.Controls.WizardPageSettings"/> class.
        /// </summary>
        /// <param name="nextButton">The next button.</param>
        /// <param name="previousButton">The previous button.</param>
        /// <param name="cancelButton">The cancel button.</param>
        /// <param name="helpButton">The help button.</param>
        /// <param name="customButton">The custom button.</param>
        public WizardPageSettings(
            WizardButtonSettings nextButton,
            WizardButtonSettings previousButton,
            WizardButtonSettings cancelButton,
            WizardButtonSettings helpButton,
            WizardButtonSettings customButton)
        {
            _nextButtonSettings = nextButton;
            _previousButtonSettings = previousButton;
            _cancelButtonSettings = cancelButton;
            _helpButtonSettings = helpButton;
            _customButtonSettings = customButton;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public WizardPageSettings Clone()
        {
            // Return the new instance
            return new WizardPageSettings(
                NextButtonSettings.Clone(), 
                PreviousButtonSettings.Clone(), 
                CancelButtonSettings.Clone(), 
                HelpButtonSettings.Clone(), 
                CustomButtonSettings.Clone());
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </returns>
        public override string ToString()
        {
            return String.Empty;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the next button settings.
        /// </summary>
        /// <value>The next button settings.</value>
        [
            Category("Button Settings"),
            Description("The Next button settings."),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
        ]
        public WizardButtonSettings NextButtonSettings
        {
            get
            {
                // Check if the settings exist
                if (_nextButtonSettings != null)
                {
                    // Return the settings
                    return _nextButtonSettings;
                }

                // Create the settings with the default values
                _nextButtonSettings = new WizardButtonSettings(DefaultNextButtonText);

                // Return the settings
                return _nextButtonSettings;
            }
            set
            {
                _nextButtonSettings = value;
            }
        }

        /// <summary>
        /// Gets or sets the previous button settings.
        /// </summary>
        /// <value>The previous button settings.</value>
        [
            Category("Button Settings"),
            Description("The Previous button settings."),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
        ]
        public WizardButtonSettings PreviousButtonSettings
        {
            get
            {
                // Check if the settings exist
                if (_previousButtonSettings != null)
                {
                    // Return the settings
                    return _previousButtonSettings;
                }

                // Create the settings with the default values
                _previousButtonSettings = new WizardButtonSettings(DefaultPreviousButtonText);

                // Return the settings
                return _previousButtonSettings;
            }
            set
            {
                _previousButtonSettings = value;
            }
        }

        /// <summary>
        /// Gets or sets the cancel button settings.
        /// </summary>
        /// <value>The cancel button settings.</value>
        [
            Category("Button Settings"),
            Description("The Cancel button settings."),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
        ]
        public WizardButtonSettings CancelButtonSettings
        {
            get
            {
                // Check if the settings exist
                if (_cancelButtonSettings != null)
                {
                    // Return the settings
                    return _cancelButtonSettings;
                }

                // Create the settings with the default values
                _cancelButtonSettings = new WizardButtonSettings(DefaultCancelButtonText);

                // Return the settings
                return _cancelButtonSettings;
            }
            set
            {
                _cancelButtonSettings = value;
            }
        }

        /// <summary>
        /// Gets or sets the help button settings.
        /// </summary>
        /// <value>The help button settings.</value>
        [
            Category("Button Settings"),
            Description("The Help button settings."),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
        ]
        public WizardButtonSettings HelpButtonSettings
        {
            get
            {
                // Check if the settings exist
                if (_helpButtonSettings != null)
                {
                    // Return the settings
                    return _helpButtonSettings;
                }

                // Create the settings with the default values
                _helpButtonSettings = new WizardButtonSettings(DefaultHelpButtonText, true, DefaultHelpButtonVisible);

                // Return the settings
                return _helpButtonSettings;
            }
            set
            {
                _helpButtonSettings = value;
            }
        }

        /// <summary>
        /// Gets or sets the custom button settings.
        /// </summary>
        /// <value>The custom button settings.</value>
        [
            Category("Button Settings"),
            Description("The Custom button settings."),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
        ]
        public WizardButtonSettings CustomButtonSettings
        {
            get
            {
                // Check if the settings exist
                if (_customButtonSettings != null)
                {
                    // Return the settings
                    return _customButtonSettings;
                }

                // Create the settings with the default values
                _customButtonSettings = new WizardButtonSettings(DefaultCustomButtonText, true, DefaultCustomButtonVisible);

                // Return the settings
                return _customButtonSettings;
            }
            set
            {
                _customButtonSettings = value;
            }
        }

        #endregion
    }
}
